<div class="layui-container fly-marginTop fly-user-main">
  {include file="common/menu" /}

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>


  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li data-type="collection" class="layui-this" data-url="/collection/find/" lay-id="collection">
          我收藏的帖（<span>{$count}</span>）
        </li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">

        <div class="layui-tab-item layui-show">
          <ul class="mine-view jie-row">
            {foreach $collection as $item}
            {if condition="!$item['deletetime']"}
            <li>
              <a class="jie-title" href="{:url('home/index/info', ['postid' => $item['postid']])}"
                target="_blank">{$item['title']}</a>
              <i>收藏于{$item['createtime']}</i>
              <a class="mine-edit" data-id="{$item['postid']}" href="javascript:0;">取消收藏</a>

              <!-- <i>收藏于23小时前</i> -->
            </li>

            {/if}
            {/foreach}
          </ul>
          {$pagestr}
          <div id="LAY_page1"></div>
        </div>
      </div>

    </div>
  </div>
</div>
<script>
  layui.use('layer', function () {
    var layer = layui.layer
    var $ = layui.jquery

    //取消收藏
    $(".mine-edit").click(function () {
      var postid = $(this).data('id')
      $.ajax({
        type: "POST",
        url: `{:url('home/collect/del')}`,
        data: `postid=${postid}`,
        dataType: "json",
        success: function (data) {
          if (data.result) {
            //成功
            layer.msg(data.msg, {
              icon: 1,
              time: 2000 //2秒关闭（如果不配置，默认是3秒）
            }, function () {
              //直接刷新界面
              location.reload()
            })
          } else {
            //失败
            layer.msg(data.msg)
          }
        }
      })
    })
  })
</script>